package com.itheima.d3_stream;

import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/*
        目标：掌握Stream流的创建。

        1 单列集合获取Stream流
        2 双列集合获取Stream流
        3 数组获取Stream流
        4 同一种类型多个数据获取Stream流
 */
public class StreamTest2 {
    public static void main(String[] args) {
        // 1、如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰","张无忌","周芷若","赵敏","张强");
        Stream<String> newNames = names.stream();
        newNames.forEach(s-> System.out.println(s));

        System.out.println();
        HashMap<String, String> map = new HashMap<>();
        map.put("典韦","赵云");
        map.put("杨过","阿1");
        map.put("小龙女","312");
        map.put("我","仍然");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        Stream<Map.Entry<String, String>> sEntries = entries.stream();
        sEntries.forEach(s-> System.out.println(s.getKey()+":"+s.getValue()));


        System.out.println();
        int[] ints=new int[]{1,2,3,4,5};
        IntStream intsS = Arrays.stream(ints);
        intsS.forEach(i-> System.out.println(i));

        System.out.println();
        String[] strs=new String[]{"1","2","3","4","5"};
        Stream<String> strsS = Arrays.stream(strs);
        intsS.forEach(i-> System.out.println(i));
        System.out.println();

        Integer[] int1s=new Integer[]{1,2,3,4,5};
        Stream<Integer> int1sS = Arrays.stream(int1s);
        int1sS.forEach(i-> System.out.println(i));

//        System.out.println();
//        int[] ints=new int[]{1,2,3,4,5};
//        IntStream intsS = Arrays.stream(ints);
//        intsS.forEach(i-> System.out.println(i));


        Stream<Integer> integerStream = Stream.of(1, 2, 3);
        integerStream.forEach(i-> System.out.println(i));

    }
}
